
import { request } from "../utils/request.js";   // 引入发送ajax的模块

export default {
    login: async ({ username, password }) =>   //async 使ajax同步
        await request({                  //await  等待ajax执行完毕
            type: "POST",
            url: "/api/admin/login",      //users路由分配请求给login
            data: { username, password }
        }),
    reg: async ({ username, password }) =>
        await request({
            type: "POST",
            url: "/api/admin/reg",
            data: { username, password }
        }),
    // 将token存储到本地服务器
    setToken: token => (localStorage["_t"] = token),
    // 获取token
    getToken: () => localStorage["_t"],
}
